import axios from 'axios';
//@ts-ignore
import { reqGet } from './axiosFun.js';

type PromistLike<T>= Promise<{
    data: T;
  state: number;
  message: string;
}>

interface sendCaseListData {
  agingData: agingData;
  dqSendConut: number;
  otherPercent: string;
  electronSendCaseNum: number;
  ybSendConut: number;
  electronicPercent: string;
  sendEndConut: number;
  zmSendConut: number;
  sendCount: number;
  hsSendConut: number;
}
interface agingData {
  all: number;
  average: number;
  electron: number;
}

//电子送达案件主要案由分布，中间的大模块数据，与电子送达比例共用一个接口。
export const sendCaseList = (params:{
  year: string,
}) :PromistLike<sendCaseListData> => reqGet('get','/dataView/sendCaseList.jhtml', params);

//送达方式模块
interface sendNumberListData {
  sendNumberCount: number;
  entrustSendCount: number;
  outSendCount: number;
  noticeSendCount: number;
  electronicSendCount: number;
  onSiteSendCount: number;
}

export const sendNumberList = (params:{
  year: string,
}) :PromistLike<sendNumberListData> => reqGet('get','/dataView/sendNumberList.jhtml', params);

//买卖合同数据统计模块

interface businessCountData {
  businessCaseNumber: number;
  electronicPercent: string;
  businessElectronicNumber: number;
  businessAverageData: number;
}

export const businessCount = (params:{
  year: string,
}) :PromistLike<businessCountData> => reqGet('get','/dataView/businessCount.jhtml', params);

// 电子送达占比情况
export interface electronCountData {
  caseNumberList: ICaseNumberListItem[];
  inProcessCaseNumber: IInProcessCaseNumberItem[];
}
export interface ICaseNumberListItem {
  endCaseNumber: number;
  newCaseNumber: number;
  month: string;
  settlementRatio: null | number;
  sendPeriod:number;
}
export interface IInProcessCaseNumberItem {
  month: string;
  number: number;
}

export const electronCount= (params:{
  year: string,
}) :PromistLike<electronCountData> => reqGet('get','/dataView/electronCount.jhtml', params);
